home *** CD-ROM | disk | FTP | other *** search
- /*
- idn.js
-
- Copyright © 2005, 2006, 2007 Against Intuition, Inc. <info@mywot.com>
- */
-
- /* Provides a simple wrapper for nsIIDNService */
- var wot_idn =
- {
- init: function()
- {
- try {
- if (this.handle) {
- return;
- }
- this.handle =
- Components.classes["@mozilla.org/network/idn-service;1"].
- getService(Components.interfaces.nsIIDNService);
-
- window.addEventListener("unload", function(e) {
- wot_idn.unload();
- }, false);
- } catch (e) {
- dump("wot_idn.init: failed with " + e + "\n");
- }
- },
-
- unload: function()
- {
- this.handle = null;
- },
-
- isidn: function(str)
- {
- try {
- return this.handle.isACE(str);
- } catch (e) {
- dump("wot_idn.isidn: failed with " + e + "\n");
- }
- return false;
- },
-
- utftoidn: function(utf)
- {
- try {
- return this.handle.convertUTF8toACE(utf);
- } catch (e) {
- dump("wot_idn.utftoidn: failed with " + e + "\n");
- }
- return null;
- },
-
- idntoutf: function(idn)
- {
- try {
- return this.handle.convertACEtoUTF8(idn);
- } catch (e) {
- dump("wot_idn.idntoutf: failed with " + e + "\n");
- }
- return null;
- }
- };
-
- wot_idn.init();
-